// with polyfills
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import permission from './directive/permission'
import style from './directive/style'
import copy from './directive/copy'
import store from './store/'
import i18n from './locales'
import {VueAxios} from './utils/request'
import ProLayout, {PageHeaderWrapper} from '@/components/ProLayout'
import FooterToolBar from '@/components/FooterToolbar'
import FileUpload from '@/components/FileUpload'
import DeviceTypeBadge from '@/components/DeviceTypeBadge'
import themePluginConfig from '../config/themePluginConfig'
import {Icon, Timeline} from 'ant-design-vue'

// mock
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
// import './mock'
import bootstrap from './core/bootstrap'
import './core/lazy_use' // use lazy load components
import './permission' // permission control
import './utils/filter' // global filter
import './global.less' // global style
import config from '@/config/defaultSettings'
import {getDictMap, getDicts} from '@/api/system/dict/data'
import {getConfigKey} from '@/api/system/config'
import {
  addDateRange,
  handleTree,
  parseTime,
  resetForm,
  selectDictLabel,
  selectDictLabels,
  tableSorter
} from '@/utils/ruoyi'
import {download} from '@/utils/request'

const IconFont = Icon.createFromIconfontCN({
  scriptUrl: '/iconfont.js'
})

// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getDictMap = getDictMap
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.tableSorter = tableSorter
Vue.prototype.tableSize = config.tableSize
Vue.prototype.$bus = new Vue()
Vue.config.productionTip = false

// mount axios to `Vue.$http` and `this.$http`
Vue.use(VueAxios)
Vue.use(Timeline)
// use pro-layout components
Vue.component('pro-layout', ProLayout)
Vue.component('page-container', PageHeaderWrapper)
Vue.component('page-header-wrapper', PageHeaderWrapper)
Vue.component('footer-tool-bar', FooterToolBar)
Vue.component('file-upload', FileUpload)
Vue.component('iot-icon', IconFont)
Vue.component('device-type-badge', DeviceTypeBadge)
// 123

Vue.use(permission)
Vue.use(style)
Vue.use(copy)

window.umi_plugin_ant_themeVar = themePluginConfig.theme
new Vue({
  router,
  store,
  i18n,
  // init localstorage, vuex
  created: bootstrap,
  render: h => h(App)
}).$mount('#app')
